home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1998 / MacHack 1998.toast / Sessions / Completions / Completions Source / Debug / DebugMessage.cp < prev    next >
Encoding:
Text File  |  1998-03-12  |  1.1 KB  |  60 lines  |  [TEXT/CWIE]

  1. // DebugMessage.cp
  2.  
  3. #ifndef DebugMessage_h
  4. #include "DebugMessage.h"
  5. #endif
  6. #ifndef Numeral_h
  7. #include "Numeral.h"
  8. #endif
  9. #ifndef ConstData_h
  10. #include "ConstData.h"
  11. #endif
  12.  
  13. uint8 DebugMessage::message[ maxuint8 + 2 ];
  14.  
  15. DebugMessage::DebugMessage()
  16.   {
  17.     Length() = 0;
  18.     message[ Length() + 1 ] = 0;
  19.   }
  20.  
  21. DebugMessage::DebugMessage( const char *string )
  22.   {
  23.     Length() = 0;
  24.     message[ Length() + 1 ] = 0;
  25.     *this << string;
  26.   }
  27.  
  28. DebugMessage& DebugMessage::operator<<( const char *string )
  29.   {
  30.     for ( uint32 i = 0; string[i] != 0 && Length() < maxuint8; i++ )
  31.         message[ ++Length() ] = string[ i ];
  32.     message[ Length() + 1 ] = 0;
  33.     return *this;
  34.   }
  35.  
  36. DebugMessage& DebugMessage::operator<<( ConstData string )
  37.   {
  38.     for ( uint32 i = 0; i < string.Length() && Length() < maxuint8; i++ )
  39.         message[ ++Length() ] = string[ i ];
  40.     message[ Length() + 1 ] = 0;
  41.     return *this;
  42.   }
  43.  
  44. DebugMessage& DebugMessage::operator<<( uint32 n )
  45.   {
  46.     return *this << Numeral( n );
  47.   }
  48.  
  49. DebugMessage& DebugMessage::operator<<( int32 n )
  50.   {
  51.     return *this << Numeral( n );
  52.   }
  53.  
  54. DebugMessage& DebugMessage::operator<<( void *p )
  55.   {
  56.     Numeral n( uint32(p), 16 );
  57.     n.PadTo( 8 );
  58.     return *this << n;
  59.   }
  60.